<template>
    <Search v-model="mSearch.data.name" placeholder="请输入姓名" @search="mSearch.onSearch" :clearable="false" />
    <bSearch :instance="mSearch">
        <span @click="router.push('addUser2')" v-if="but.has('addUser1')" class="textbutton">({{ pList.total }}) {{
            but.get('addUser1')
            }}</span>
    </bSearch>
    <bList :instance="pList" @about="(item, index) => but.has('userDetail2')
        && router.push(`/userDetail2?id=${item.id}&index=${index}`)">
    </bList>
</template>

<script lang="ts" setup>
import bSearch from "@m/components/public/b_search.vue";
import bList from "@m/components/public/b_list.vue";
import { Search } from "vant";
import { UserListSearch, Userlist } from '@b/index/user'
import { pagebuttonStore } from "@b/store";
import { useRouter } from "vue-router";

const mSearch = new UserListSearch()
const pList = new Userlist()
const router = useRouter()
const but = pagebuttonStore().button

mSearch.init()
mSearch.onSearch = () => {
    //解构（防止存在查询条件时点击页码产生的混乱）
    pList.search_key = mSearch.getData()
    pList.refresh(1)
    mSearch.show = false
}
pList.routertoC2C = (C2CId: number) => {
    router.push(`C2CList?id=${C2CId}`)
}
</script>
<style scoped>
.left-button {
    color: var(--van-danger-color);
}
</style>